<form action="{:sysuri()}" method="post" data-auto="true" class="layui-form layui-card">

    <div class="layui-card-body padding-left-40">

        <div class="layui-row layui-form-item layui-col-space15">
            <label class="layui-form-item relative block">
                <span class="help-label"><b>标记打款金额</b></span>
                <input class="layui-input" type="number" name="amount" placeholder="请输入打款金额" required value="{$amount|default=0}" readonly max="{$amount|default=0}" onkeyup="checkAmount()"/>
                <span class="help-block">可标记金额：{$amount|default=0}</span>
            </label>
            <label class="layui-col-xs3 label-required-prev">
                <span class="help-label"><b>上传打款凭证</b></span>
                <div class="help-images">
                    <input name="path" data-max-width="500" data-max-height="500" type="hidden" value="">
                    <script>$('[name="path"]').uploadOneImage();</script>
                </div>
            </label>
        </div>
    </div>
    <div class="hr-line-dashed"></div>
    {notempty name='id'}<input name='id' type='hidden' value='{$id}'>{/notempty}

    <div class="layui-form-item text-center">
        <button class="layui-btn pre_submit" type='button'>提交</button>
        <button class="layui-btn true_submit" style="display: none;" type='submit'>提交</button>
    </div>
</form>
<script>
    let _max_amount = "{$amount|default=0}";
    $(function (){
        $(".pre_submit").bind().on("click",function(){
            if(checkAmount()) {
                if($("input[name='path']").val().length == 0){
                     layer.alert('凭证必填');
                        return false;
                }
                $(".true_submit").trigger('click')
            }
        })
    })
    function checkAmount(){
        let _amount = $("input[name='amount']").val();
        if(Number(_amount) > Number(_max_amount)){
            layer.alert('标记打款金额有误，请确认');
            return false;
        }
        return true;
    }
</script>
